<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 7.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/ME.ico">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/ME.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/ME.ico">
  <link rel="mask-icon" href="/images/ME.ico" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"www.zhoubencheng.com","root":"/","scheme":"Pisces","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":true,"style":"mac"},"back2top":{"enable":true,"sidebar":false,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="插值多项式  什么是插值问题？ 已知一系列离散点，需要找到一个多项式，在这些结点上数值相等，其他结点上数值近似，所以插值公式存在以下两个问题  不是次数越高越好 存在误差，详见插值多项式的余项">
<meta property="og:type" content="article">
<meta property="og:title" content="插值与拟合">
<meta property="og:url" content="http://www.zhoubencheng.com/2024/04/23/%E6%8F%92%E5%80%BC%E4%B8%8E%E6%8B%9F%E5%90%88/index.html">
<meta property="og:site_name" content="Benson&#39;s blog">
<meta property="og:description" content="插值多项式  什么是插值问题？ 已知一系列离散点，需要找到一个多项式，在这些结点上数值相等，其他结点上数值近似，所以插值公式存在以下两个问题  不是次数越高越好 存在误差，详见插值多项式的余项">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://i.postimg.cc/XYsWFxcC/Newton.png">
<meta property="article:published_time" content="2024-04-23T15:39:41.000Z">
<meta property="article:modified_time" content="2024-07-05T07:06:54.331Z">
<meta property="article:author" content="Benson">
<meta property="article:tag" content="数值计算">
<meta property="article:tag" content="高等数学">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://i.postimg.cc/XYsWFxcC/Newton.png">

<link rel="canonical" href="http://www.zhoubencheng.com/2024/04/23/%E6%8F%92%E5%80%BC%E4%B8%8E%E6%8B%9F%E5%90%88/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>插值与拟合 | Benson's blog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>


<style>.github-emoji { position: relative; display: inline-block; width: 1.2em; min-height: 1.2em; overflow: hidden; vertical-align: top; color: transparent; }  .github-emoji > span { position: relative; z-index: 10; }  .github-emoji img, .github-emoji .fancybox { margin: 0 !important; padding: 0 !important; border: none !important; outline: none !important; text-decoration: none !important; user-select: none !important; cursor: auto !important; }  .github-emoji img { height: 1.2em !important; width: 1.2em !important; position: absolute !important; left: 50% !important; top: 50% !important; transform: translate(-50%, -50%) !important; user-select: none !important; cursor: auto !important; } .github-emoji-fallback { color: inherit; } .github-emoji-fallback img { opacity: 0 !important; }</style>
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Benson's blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">最好的安排</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

  <a href="https://github.com/ZhouBencheng" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://www.zhoubencheng.com/2024/04/23/%E6%8F%92%E5%80%BC%E4%B8%8E%E6%8B%9F%E5%90%88/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/ME.ico">
      <meta itemprop="name" content="Benson">
      <meta itemprop="description" content="Share my thoughts with you">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Benson's blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          插值与拟合
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2024-04-23 23:39:41" itemprop="dateCreated datePublished" datetime="2024-04-23T23:39:41+08:00">2024-04-23</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2024-07-05 15:06:54" itemprop="dateModified" datetime="2024-07-05T15:06:54+08:00">2024-07-05</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/USTB-courses/" itemprop="url" rel="index"><span itemprop="name">USTB courses</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="插值多项式">插值多项式</h2>
<blockquote>
<p>什么是插值问题？</p>
<p>已知一系列离散点，需要找到一个多项式，在这些结点上<strong>数值相等</strong>，其他结点上<strong>数值近似</strong>，所以插值公式存在以下两个问题</p>
<ul>
<li>不是次数越高越好</li>
<li>存在误差，详见<a href="#插值多项式余项推导">插值多项式的余项</a></li>
</ul>
</blockquote>
<span id="more"></span>
<p>对于目标插值多项式<span class="math inline">\(p_n(x) =
a_0+a_1x+a_2x^2+...+a_nx^n\)</span>，列出一下方程 <span class="math display">\[
\begin{cases}
a_0+a_1x_0+a_2{x_0}^2+....+a_n{x_0}^n = f(x_0)\\
a_0+a_1x_1+a_2{x_1}^2+....+a_n{x_1}^n = f(x_1)\\
......\\
a_0+a_1x_n+a_2{x_n}^2+....+a_n{x_n}^n = f(x_n)
\end{cases}
\]</span> 显然<span class="math inline">\(x_0 \thicksim
x_n\)</span>和<span class="math inline">\(f(x_0) \thicksim
f(x_n)\)</span>都是已知量，所以提取系数矩阵，得到经典Vandacomde行列式
<span class="math display">\[
\begin{vmatrix}
1 &amp; x_0 &amp; {x_0}^2 &amp; ... &amp; {x_0}^n\\
1 &amp; x_1 &amp; {x_1}^2 &amp; ... &amp; {x_1}^n\\
... &amp; ...\\
1 &amp; x_n &amp; {x_n}^2 &amp; ... &amp; {x_n}^n\\
\end{vmatrix}
\]</span> 由给定离散点可知，所有<span class="math inline">\(x_i\)</span>都不相等，所以该Vandamonde行列式不为0，因此系数有唯一解</p>
<p>但是一般计算差值不等式的待定系数时不会硬解线性方程组，因此下面引入两种插值方法——<strong>lagrange插值公式</strong>和<strong>Newton插值公式</strong></p>
<h2 id="插值多项式余项推导">插值多项式余项推导</h2>
<p>插值多项式余项定理：</p>
<p>若<span class="math inline">\(f(x)\)</span>在区间<span class="math inline">\([a, b]\)</span>上有直到<span class="math inline">\(n+1\)</span>阶导数，<span class="math inline">\(p_n(x)\)</span>为<span class="math inline">\(f(x)\)</span>在n+1各结点下的n次插值多项式，则对<span class="math inline">\(\forall x \in [a, b]\)</span>都有 <span class="math display">\[
R_n(x) = f(x) - p_n(x) = \frac{f^{(n+1)}(\xi)}{(n+1)!}w_{n+1}(x)
\\其中w_{n+1}(x) = \prod_{i = 0}^{n}(x - x_i)
\]</span></p>
<blockquote>
<p>余项公式证明如下：</p>
<p>已知原函数<span class="math inline">\(f(x)\)</span>，我们将用n次插值多项式<span class="math inline">\(p_n(x)\)</span>去拟合</p>
<p>设<span class="math inline">\(R_n(x) = f(x) - p_n(x)\)</span>,
其中插值点<span class="math inline">\(x_0, x_1,
...x_n\)</span>带入时<span class="math inline">\(p_n(x)\)</span>完全等于<span class="math inline">\(f(x)\)</span>，因此我们可以确定<span class="math inline">\(R_n(x)\)</span>一定有零点<span class="math inline">\(x_0, x_1, ...x_n\)</span></p>
<p>因此设 <span class="math display">\[
f(x) = p_n(x) + k(x)w_{n+1}(x) \\即 R_n(x) = k(x)w_{n+1}(x)
\]</span></p>
<p>此时我们要求的是待定系数<span class="math inline">\(k(x)\)</span></p>
<p>设辅助函数 <span class="math display">\[
F(t) = f(t) - p_n(t) - k(x)w_{n+1}(t)\\
其中 x为[a, b]中任意一个不等于x_i的存在，而t为[a, b]中任意值
\]</span>
注意这一步中，我们采用变换主元法，将主元设置为<code>t</code>，而<code>x</code>变为参量</p>
<p>根据这一个辅助函数，我们可以得到以下两个推论</p>
<p>推论一： <span class="math display">\[
F(x) = F(x_0) = F(x_1) = ... = F(x_n) = 0\\
当主元t = x时，原函数f(x)和p_n(x) + k(x)w_{n+1}(x)完全相等，因此有t =
x这个零点
\]</span> 推论二：</p>
<p>对主元t进行求导，得 <span class="math display">\[
F^{(n+1)}(t) = f^{(n+1)}(x) - k(x)(n+1)!\\
\]</span> p_n(x)为n次多项式，因此在n+1阶求导后归零，<span class="math inline">\(w_{n+1}(x)\)</span>为n+1阶多项式，首项系数为1，因此求导后得到阶乘</p>
<p>根据推论一，得到F(x)有n+2个零点，根据Rolle定理，得到F‘(x)有n+1个零点，以此类推，最终得到<span class="math inline">\(F^{(n+1)}(x)\)</span>至少有一个零点</p>
<p>设该零点为<span class="math inline">\(x = \xi\)</span>，得到 <span class="math display">\[
f^{(n+1)}(x) - k(x)(n+1)! = 0\\
\Rightarrow k(x) = \frac{f^{(n+1)}(x)}{(n+1)!}\\
余项R_n(x) = k(x)w_{n+1}(x) = \frac{f^{(n+1)}(x)}{(n+1)!}w_{n+1}(x)
\]</span> 得证</p>
</blockquote>
<h2 id="lagrange插值公式">Lagrange插值公式</h2>
<p>Lagrange插值公式适用于<strong>一次性给定所有已知点</strong>的多项式待定系数计算，其公式如下
<span class="math display">\[
对于给定的离散点x_i(0 \le i \le n)和y_i(0 \le i \le n)\\
p_n(x) = \sum_{i = 0}^{n}y_i\prod_{j = 0 \atop j \ne
i}^{n}\frac{x-x_j}{x_i-x_j}
\]</span> 注意Lagrange插值公式的<strong>基函数</strong>为 <span class="math display">\[
l_k(x_i) =
\begin{cases}
1, i = k\\
0, i \ne k
\end{cases}
\]</span> 这样的基函数对标上一条Lagrange插值公式中<span class="math inline">\(y_i\)</span>右侧的连乘部分</p>
<h2 id="newton插值公式">Newton插值公式</h2>
<h3 id="newton插值公式-1">Newton插值公式</h3>
<p>Newton插值公式适用于节点数存在变化的离散点进行插值，公式如下 <span class="math display">\[
p_n(x) = f(x_0) + \sum_{i=1}^{n}f[x_0,...x_i]\prod_{j=0 \atop j \ne
i}^{i-1}(x-x_j)
\]</span> 注意Newton插值公式的<strong>基函数</strong>为<span class="math inline">\(\begin{cases}\psi_0(x)=1\\ \psi_i(x)=
\prod_{j=0}^{i-1}(x-x_j) \end{cases}\)</span></p>
<blockquote>
<p>此处列出差商公式 <span class="math display">\[
f[x_0, x_1, ..., x_n] = \frac{f[x_1, x_2, ..., x_n] - f[x_0, x_1,
...,x_{n-1}]}{x_n - x_0}
\]</span> 以及其等价变式 <span class="math display">\[
f[x_0, x_1, ..., x_n] = \frac{f[x_1, x_2, ..., x_{n - 2}, x_{n}] -
f[x_0, x_1, ...,x_{n-1}]}{x_n - x_{n-1}}\\
此处可以理解为分子右边中的x_{n-1}元素是x_0之前的一个元素，这样就能与上一条公式对齐
\]</span></p>
</blockquote>
<h3 id="newton插值公式推导">Newton插值公式推导</h3>
<p>由一阶插值公式可得 <span class="math display">\[
f(x) = f(x_0) + f[x, x_0](x - x_0)
\]</span></p>
<blockquote>
<p>此时使用插值递推公式 <span class="math display">\[
f[x, x_0, x_1, ..., x_n] = \frac{f[x, x_0, x_1, ..., x_{n-1}] - f[x_0,
x_1, ..., x_n]}{x-x_n}\\
\Rightarrow f[x, x_0, x_1, ..., x_{n-1}] = f[x_0, x_1, ..., x_n] + (x -
x_n)f[x, x_0, x_1, ..., x_n]\\
此递推公式旨在当已知点从x_{n-1}扩展到x_n时，使用该式进行差商地推
\]</span></p>
</blockquote>
<p>因此有如下Newton插值公式递推过程</p>
<p><img src="https://i.postimg.cc/XYsWFxcC/Newton.png" style="zoom: 50%;"></p>
<h3 id="newton插值公式余项">Newton插值公式余项</h3>
<p>由上述Newton插值公式推导过程中显示的余项可以看出 <span class="math display">\[
R_n(x) = f[x, x_0, x_1, ...., x_n]w_{n+1}(x)
\]</span> 对比插值多项式的统一余项公式 <span class="math display">\[
R_n(x) = \frac{f^{(n+1)}(\xi)}{(n+1)!}w_{n+1}(x)
\]</span> 得到 <span class="math display">\[
\frac{f^{(n+1)}(\xi)}{(n+1)!} = f[x, x_0, x_1, ...., x_n]， \xi \in
(a,b)
\]</span> 由此可以看出<strong>差商和导数的关系</strong></p>
<h2 id="分段低次插值">分段低次插值</h2>
<p>为了避免引用所有已知点而造成插值<code>过拟合</code>的现象，在某些问题中可以采用分段低次插值的方法，也就是只是用一系列已知点中的部分(只用两个点的线性插值、只用三个点的二次插值)来求插值多项式中某一个未知点的函数值</p>
<h2 id="hermite插值">Hermite插值</h2>
<blockquote>
<p>引理：当有n+1个条件数时，则至高能构造出n阶插值多项式</p>
<p>这里条件数指的是已知函数点或者是已知导数点(<strong>任意阶</strong>导数)</p>
</blockquote>
<p><strong>解题步骤</strong></p>
<ol type="1">
<li>确定多项式次数（条件数减一）</li>
<li>使用已知的函数点个数先构造Lagrange插值多项式（Newton也可，但计算量随已知点增多而增多），在后面添加形如<span class="math inline">\((x-x_i)，
(x_i为函数已知点)\)</span>的连乘式，为了能够凑齐多项式整体的次数，需要在这个连乘式前乘形如<span class="math inline">\(A+Bx+Cx^2+...\)</span>的多项式，这里的待定系数多项式次数具体由需要补齐的
次数而定（也可以说由当前已知的导数数量而定）</li>
<li>对待定系数的多项式进行求导，带入导数值，对所有待定系数进行求解</li>
</ol>
<h2 id="最小二乘法拟合">最小二乘法拟合</h2>
<p>当我们不需要确切拟合每一个已知函数点的时候，仅需要拟合出“形状”，此时可以考虑最小二乘法拟合</p>
<h3 id="最小二乘法拟合函数">最小二乘法拟合函数</h3>
<p>设我们最终要求的函数为<span class="math inline">\(\psi(x)\)</span>，则<span class="math inline">\(\psi(x)\)</span>要满足一下这个特点 <span class="math display">\[
\sum_{i = 0}^{n} [\psi(x_i) - y_i]^2 为最小值
\]</span> 我们要解决的问题就是找到这个<span class="math inline">\(\psi(x)\)</span>来满足最小二乘判定的最小值</p>
<h3 id="最小二乘法函数推导">最小二乘法函数推导</h3>
<p>设<span class="math inline">\(\psi(x) = F(a_0, a_1, a_2, ..., a_n,
x)，
这里F函数是以a_i为系数，x为主元的多项式函数\)</span>，则我们要求得函数满
足以下特性 <span class="math display">\[
S(a_0, a_1, a_2, ..., a_m) = \sum_{i = 0}^{n}[F(a_0, a_1, a_2, ..., a_m,
x_i) - y_i]^2 为最小值\\
\]</span></p>
<blockquote>
<p>以上公式注意两点</p>
<ol type="1">
<li><p>这里使用已知点带入x_i，该式的本质已经从一个一元多项式函数变成了多元一次多项式</p></li>
<li><p>这里多项式F的次数仅使用到m，多项式次数m和已知点n（已知量n+1）是<span class="math inline">\(m \le
n\)</span>的关系。因为当次数提高到m，意味着多项式待定系数有m+1个，而已知量只有n+1组，因此从线性方程组可解性上来判断，待定系数的数量也受此限制</p></li>
</ol>
</blockquote>
<p>根据多元函数最小值判定的必要条件，得到 <span class="math display">\[
\frac{\partial S}{\partial a_i} = 0, i \in [0, m]
\]</span> 此时进行推广，我们一般不会一直使用多项式（or
幂函数）去做最小二乘法拟合，有时也会使用其他的初等函数比如<span class="math inline">\(sinx、e^x\)</span>等</p>
<p>因此设<span class="math inline">\(\psi(x) = a_0\psi_0(x) +
a_1\psi_1(x) + a_2\psi_2(x) + ... + a_m\psi_m(x)\)</span></p>
<p>此时由<span class="math inline">\(\frac{\partial S}{\partial a_i} =
0\)</span>可得到如下方程组</p>
<p><span class="math display">\[
\sum_{i=0}^{n}\psi_k(x_i)[a_0\psi_0(x_i) + a_1\psi_1(x_i) +
a_2\psi_2(x_i) + ... + a_m\psi_m(x_i) - y_i] = 0, k \in [0, m]
\]</span></p>
<p>此处引用如下记号</p>
<p><span class="math display">\[
\begin{cases}
(\psi_k, \psi_j) = \sum_{i = 0}^{n}\psi_k(x_i)\psi_j(x_i)\\
(\psi_k, f) = \sum_{i = 0}^{n}\psi_k(x_i)y_i
\end{cases}
\]</span></p>
<p>因此可以将上一条列出的线性方程组转化为矩阵乘积</p>
<p><span class="math display">\[
\begin{bmatrix}
(\psi_0, \psi_0) &amp; (\psi_0, \psi_1) &amp; ... &amp; (\psi_0,
\psi_n)\\
(\psi_1, \psi_0) &amp; (\psi_1, \psi_1) &amp; ... &amp; (\psi_1,
\psi_n)\\
: &amp; : &amp;  &amp; :\\
(\psi_n, \psi_0) &amp; (\psi_n, \psi_1) &amp; ... &amp; (\psi_n, \psi_n)
\end{bmatrix}
\begin{bmatrix}
a_0\\a_1\\:\\a_n
\end{bmatrix}
=
\begin{bmatrix}
(\psi_0, y_0)\\(\psi_1, y_1)\\:\\(\psi_n, y_n)
\end{bmatrix}
\]</span></p>

    </div>

    
    
    

      <footer class="post-footer">
          
          <div class="post-tags">
              <a href="/tags/%E6%95%B0%E5%80%BC%E8%AE%A1%E7%AE%97/" rel="tag"><i class="fa fa-tag"></i> 数值计算</a>
              <a href="/tags/%E9%AB%98%E7%AD%89%E6%95%B0%E5%AD%A6/" rel="tag"><i class="fa fa-tag"></i> 高等数学</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2024/04/20/%E5%B8%B8%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B%E6%95%B0%E5%80%BC%E8%A7%A3%E6%B3%95/" rel="prev" title="常微分方程数值解法">
      <i class="fa fa-chevron-left"></i> 常微分方程数值解法
    </a></div>
      <div class="post-nav-item">
    <a href="/2024/04/24/%E6%95%B0%E5%80%BC%E7%A7%AF%E5%88%86%E6%96%B9%E6%B3%95/" rel="next" title="数值积分方法">
      数值积分方法 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%8F%92%E5%80%BC%E5%A4%9A%E9%A1%B9%E5%BC%8F"><span class="nav-number">1.</span> <span class="nav-text">插值多项式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%8F%92%E5%80%BC%E5%A4%9A%E9%A1%B9%E5%BC%8F%E4%BD%99%E9%A1%B9%E6%8E%A8%E5%AF%BC"><span class="nav-number">2.</span> <span class="nav-text">插值多项式余项推导</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#lagrange%E6%8F%92%E5%80%BC%E5%85%AC%E5%BC%8F"><span class="nav-number">3.</span> <span class="nav-text">Lagrange插值公式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#newton%E6%8F%92%E5%80%BC%E5%85%AC%E5%BC%8F"><span class="nav-number">4.</span> <span class="nav-text">Newton插值公式</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#newton%E6%8F%92%E5%80%BC%E5%85%AC%E5%BC%8F-1"><span class="nav-number">4.1.</span> <span class="nav-text">Newton插值公式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#newton%E6%8F%92%E5%80%BC%E5%85%AC%E5%BC%8F%E6%8E%A8%E5%AF%BC"><span class="nav-number">4.2.</span> <span class="nav-text">Newton插值公式推导</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#newton%E6%8F%92%E5%80%BC%E5%85%AC%E5%BC%8F%E4%BD%99%E9%A1%B9"><span class="nav-number">4.3.</span> <span class="nav-text">Newton插值公式余项</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%88%86%E6%AE%B5%E4%BD%8E%E6%AC%A1%E6%8F%92%E5%80%BC"><span class="nav-number">5.</span> <span class="nav-text">分段低次插值</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#hermite%E6%8F%92%E5%80%BC"><span class="nav-number">6.</span> <span class="nav-text">Hermite插值</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%9C%80%E5%B0%8F%E4%BA%8C%E4%B9%98%E6%B3%95%E6%8B%9F%E5%90%88"><span class="nav-number">7.</span> <span class="nav-text">最小二乘法拟合</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%9C%80%E5%B0%8F%E4%BA%8C%E4%B9%98%E6%B3%95%E6%8B%9F%E5%90%88%E5%87%BD%E6%95%B0"><span class="nav-number">7.1.</span> <span class="nav-text">最小二乘法拟合函数</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%9C%80%E5%B0%8F%E4%BA%8C%E4%B9%98%E6%B3%95%E5%87%BD%E6%95%B0%E6%8E%A8%E5%AF%BC"><span class="nav-number">7.2.</span> <span class="nav-text">最小二乘法函数推导</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Benson"
      src="/images/ME.ico">
  <p class="site-author-name" itemprop="name">Benson</p>
  <div class="site-description" itemprop="description">Share my thoughts with you</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">17</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">7</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">25</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/ZhouBencheng" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;ZhouBencheng" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:zhoubencheng2022@163.com" title="E-Mail → mailto:zhoubencheng2022@163.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2024</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Benson</span>
</div>

<!--
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://pisces.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Pisces</a> 强力驱动
  </div>
-->

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>


  <script defer src="/lib/three/three.min.js"></script>
    <script defer src="/lib/three/canvas_lines.min.js"></script>


  













<script>
if (document.querySelectorAll('pre.mermaid').length) {
  NexT.utils.getScript('//cdn.jsdelivr.net/npm/mermaid@8/dist/mermaid.min.js', () => {
    mermaid.initialize({
      theme    : 'dark',
      logLevel : 3,
      flowchart: { curve     : 'linear' },
      gantt    : { axisFormat: '%m/%d/%Y' },
      sequence : { actorMargin: 50 }
    });
  }, window.mermaid);
}
</script>


  

  
      

<script>
  if (typeof MathJax === 'undefined') {
    window.MathJax = {
      loader: {
        source: {
          '[tex]/amsCd': '[tex]/amscd',
          '[tex]/AMScd': '[tex]/amscd'
        }
      },
      tex: {
        inlineMath: {'[+]': [['$', '$']]},
        tags: 'ams'
      },
      options: {
        renderActions: {
          findScript: [10, doc => {
            document.querySelectorAll('script[type^="math/tex"]').forEach(node => {
              const display = !!node.type.match(/; *mode=display/);
              const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display);
              const text = document.createTextNode('');
              node.parentNode.replaceChild(text, node);
              math.start = {node: text, delim: '', n: 0};
              math.end = {node: text, delim: '', n: 0};
              doc.math.push(math);
            });
          }, '', false],
          insertedScript: [200, () => {
            document.querySelectorAll('mjx-container').forEach(node => {
              let target = node.parentNode;
              if (target.nodeName.toLowerCase() === 'li') {
                target.parentNode.classList.add('has-jax');
              }
            });
          }, '', false]
        }
      }
    };
    (function () {
      var script = document.createElement('script');
      script.src = '//cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js';
      script.defer = true;
      document.head.appendChild(script);
    })();
  } else {
    MathJax.startup.document.state(0);
    MathJax.texReset();
    MathJax.typeset();
  }
</script>

    

  

</body>
</html>
